/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aslan
 */
@Entity
@Table(name = "has_subject")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HasSubject.findAll", query = "SELECT h FROM HasSubject h"),
    @NamedQuery(name = "HasSubject.findByUserId", query = "SELECT h FROM HasSubject h WHERE h.hasSubjectPK.userId = :userId"),
    @NamedQuery(name = "HasSubject.findBySubjectId", query = "SELECT h FROM HasSubject h WHERE h.hasSubjectPK.subjectId = :subjectId")})
public class HasSubject implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HasSubjectPK hasSubjectPK;

    public HasSubject() {
    }

    public HasSubject(HasSubjectPK hasSubjectPK) {
        this.hasSubjectPK = hasSubjectPK;
    }

    public HasSubject(int userId, int subjectId) {
        this.hasSubjectPK = new HasSubjectPK(userId, subjectId);
    }

    public HasSubjectPK getHasSubjectPK() {
        return hasSubjectPK;
    }

    public void setHasSubjectPK(HasSubjectPK hasSubjectPK) {
        this.hasSubjectPK = hasSubjectPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (hasSubjectPK != null ? hasSubjectPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HasSubject)) {
            return false;
        }
        HasSubject other = (HasSubject) object;
        if ((this.hasSubjectPK == null && other.hasSubjectPK != null) || (this.hasSubjectPK != null && !this.hasSubjectPK.equals(other.hasSubjectPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.HasSubject[ hasSubjectPK=" + hasSubjectPK + " ]";
    }
    
}
